<template>
  <div>
    <Header_h />
    <div class="sq_box_content">
      <bannerInfo :info="info" />
    </div>
    <div class="new_box">
      <div class="container">
        <div class="s_flex s_align_items_start">
          <leftMenu :menu="menu" :check="active" @checkItem="checkItem" />
          <section class="core_content_left core_content_lefts">
            <div>
              <div>
                <h3
                  class="
                    sq_tilte3 sq_h3
                    line_h_30
                    sq_tilte_color
                    ft_weight_800
                    sq_tilte_color
                  "
                >
                  {{ list.title }}
                </h3>
                <p class="sq_content sq_content_color">
                  {{ list.online_time }}
                </p>
              </div>
              <div
                class="sq_html sq_content line_h_26 sq_content_color"
                v-html="list.content"
              ></div>
              <div
                class="
                  new_footer
                  s_flex s_justify_content_between s_align_items_center
                  sq_content sq_content_color
                  ft_weight_400
                "
              >
                <div @click="prev">
                  <i class="iconfont icon-fanhuijian"></i> 上一篇
                </div>
                <div @click="next">
                  下一篇 <i class="iconfont icon-jiantou1"></i>
                </div>
              </div>
            </div>
          </section>
        </div>
      </div>
    </div>
    <Footer />
    <rightMenu @moveTo="moveTo" />
  </div>
</template>

<script>
import Header_h from "@/components/Header_h";
import Footer from "@/components/Footer";
import bannerInfo from "@/components/web/bannerInfo";
import leftMenu from "@/components/web/leftMenu";
import { newsInfo } from "@/api/web";
import rightMenu from "@/components/web/rightMenu";

export default {
  components: {
    Header_h,
    Footer,
    bannerInfo,
    leftMenu,
    rightMenu,
  },
  data() {
    return {
      list: [],
      banner: [],
      info: {
        title: "新闻资讯",
        content: "最新的中心动态及资讯",
        img: require("@/assets/web/banner.png"),
      },
      check: -1,
      active: 3,
      menu: [
        {
          name: "中心介绍",
          path: "/web/services/introduce",
        },
        // {
        //   name: "顺企动态",
        //   path: "/web/services/dynamic",
        // },
        {
          name: "培训活动",
          path: "/web/services/central",
        },
        {
          name: "新闻资讯",
          path: "/web/news",
        },
      ],
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    moveTo() {
      window.scrollTo(0, 0);
    },
    async getList() {
      try {
        this.list = await newsInfo({ news_id: this.$route.query.id });
      } catch (error) {
        this.$message.error(error.message);
      }
    },
    async prev() {
      if (this.list.prev) {
        try {
          this.list = await newsInfo({ news_id: this.list.prev });
        } catch (error) {
          this.$message.error(error.message);
        }
      } else {
        this.$message.success("暂无数据");
      }
    },
    async next() {
      if (this.list.next) {
        try {
          this.list = await newsInfo({ news_id: this.list.next });
        } catch (error) {
          this.$message.error(error.message);
        }
      } else {
        this.$message.success("暂无数据");
      }
    },
    checkItem(index) {
      this.active = index;
    },
  },
};
</script>

<style lang="less" scoped>
/* core_content */
.new_box {
  margin-top: -4%;
  position: relative;
  z-index: 1;
  margin-bottom: 60px;
}
.core_content .item_list_img {
  width: 240px;
  object-fit: cover;
  overflow: hidden;
  .img_wap {
    padding-bottom: 56%;
    width: 100%;
    position: relative;
    img {
      width: 100%;
      transition: all 0.5s ease;
      &:hover {
        transform: scale(1.1);
      }
    }
  }
}

.li_active {
  width: 100%;
  background: #ffffff;
  box-shadow: 0 0 16px rgba(24, 76, 171, 0.16);
  border: none;
}

.right_info {
  width: 70%;
  margin-left: 25px;
}

.core_content .item_list {
  border-bottom: 1px solid #eee;
  padding: 23px 15px;
  width: 100%;
  margin-bottom: 30px;
  background: #ffffff;
  border: 1px solid #ced4ea;
  cursor: pointer;
  transition: all 0.2s ease;
}

.content_spacing {
  margin: 22px auto 25px;
}
.core_content_left {
  width: 80%;
  margin-left: 250px;
  background-color: #fff;
  height: 100%;
  box-shadow: 0px 0px 21px 0px rgba(97, 97, 102, 0.23);
  padding: 30px;
  // margin-bottom:25px;
}
.core_content_right {
  width: 25%;
  background-color: #fff;
}
.content_right_spacing {
  margin: 10px 0;
}
.list_right {
  border-top: 1px solid #eee;
  padding: 10px 0;
  margin: 0 10px;
}
.right_title {
  margin: 0 10px;
  padding: 10px 0;
}

.sq_h3 {
  margin-bottom: 30px;
}

.sq_html {
  border-top: 1px solid var(--color9);
  border-bottom: 1px solid var(--color9);
  padding: 30px 0;
  margin-top: 25px;
  /deep/ img {
    max-width: 100%;
    margin: 0 auto;
  }
  /deep/ p {
    word-break: break-all;
  }
}

.new_footer {
  margin-top: 45px;
  div:hover {
    color: var(--color);
    cursor: pointer;
  }
  .iconfont {
    font-size: 12px;
  }
}

/* core_content */

@media (max-width: 750px) {
  .core_content .item_list_img {
    width: 100%;
    height: 127px;
    margin-right: 0;
    margin-bottom: 20px;
  }
}
</style>

